package cn.smile.controller;

import cn.smile.pojo.User;
import com.netflix.ribbon.proxy.annotation.Hystrix;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.sql.Timestamp;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: MaoSuyu
 * @User：John
 * @Date: 2019/5/18
 * @Time: 13:44
 * @Description: No Description
 */
@RestController
public class TestController {

    @PostMapping("/hello")
    public User user(){
        return new User("毛苏雨",new Timestamp(System.currentTimeMillis()));
    }

    @PostMapping("/getUser")
    public User getUser(@RequestBody User user){
        System.out.println(user.toString());
        return user;
    }

    @PostMapping("/test")
    public String test(){
        try{
            Thread.sleep(1500);
        }catch (InterruptedException e){
            e.printStackTrace();
        }
        return "Timeout-Test-测试";
    }

    @PostMapping("/hystrix")
    public String hystrix(){
        try{
            Thread.sleep(10000);
        }catch (InterruptedException e){
            e.printStackTrace();
        }
        return "Hystrix-Test-测试";
    }

    @PostMapping("/server")
    public String getServerName(){
        return "我是服务器2";
    }

}
